<%@page import="com.easy.system.domain.Lov"%>
<%@page import="com.easy.base.domain.EObject"%>
<%@page import="com.easy.base.service.impl.ESession"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
	ESession eSession = ESession.create(session);
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=eSession.local("lov.jsp.Title", "字典管理") %></title>
<%@include file="/jsp/include/common.jsp"%>
</head>
<body class="easyui-layout">
	<%@include file="/jsp/include/commonLayout.jsp"%>
	<div data-options="region:'center',">
			<table id="dg" title="字典管理" style="width: 100%; height: auto"
				toolbar="#toolbar" pagination="true" idField="oid" rownumbers="true"
				fitColumns="true" singleSelect="true">
				<thead>
					<tr>
						<th field="dictType" width="100" editor="text" sortable="true" data-options="validType : 'length[0,30]',required : true,"><%=eSession.local("lov.zidianmingcheng", "类别")%></th>
						<th field="subType" width="100" editor="text" sortable="true" data-options="validType : 'length[0,30]',required : true,"><%=eSession.local(Lov.class, "ky", "Key")%></th>
						<th field="oname" width="150" editor="text" sortable="true" editor="{type:'validatebox',options:{required:true}}"> <%=eSession.local("lov.shuxingzhimingcheng", "属性值")%></th>
						<th field="odesc" width="250" editor="text" data-options="validType : 'length[0,30]',required : true,"><%=eSession.local(EObject.class, "creater", "详细信息")%></th>
						<th field="oid" width="250" hidden="true" sortable="true"><%=eSession.local(EObject.class, "oid", "OID")%></th>
					</tr>
				</thead>
			</table>
			<div id="toolbar">
				 <% 
			String itemFormKey = "itemForm.竞品配置.数据字典";
			if (itemFormKey != null && eSession.hasSave(itemFormKey)) {
		%>
				<a href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-add" plain="true"
					onclick="javascript:$('#dg').edatagrid('addRow')"><%=eSession.local("common.add", "新建")%></a>
				<%} %>
				 <% 
			itemFormKey = "itemForm.竞品配置.数据字典";
			if (itemFormKey != null && eSession.hasRemove(itemFormKey)) {
		%>
				<a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-remove" plain="true"
					onclick="javascript:$('#dg').edatagrid('destroyRow')"><%=eSession.local("common.remove", "删除")%></a> 
				<%} %>
				<% 
			itemFormKey = "itemForm.竞品配置.数据字典";
			if (itemFormKey != null && (eSession.hasEdit(itemFormKey)||eSession.hasSaveAs(itemFormKey))) {
		%>
				<a href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-ok" plain="true"
					onclick="savelov()"><%=eSession.local("common.save", "保存")%></a>
				<%} %><!-- javascript:$('#dg').edatagrid('saveRow') -->
					 <% 
			itemFormKey = "itemForm.竞品配置.数据字典";
			if (itemFormKey != null && eSession.hasImport(itemFormKey)) {
		%>
				<%} %>
				 <% 
			itemFormKey = "itemForm.竞品配置.数据字典";
			if (itemFormKey != null && eSession.hasEdit(itemFormKey)) {
		%>
				<%} %>
			</div>
			<!-- 导入开始-->
			<div id="lovManageDlg" class="easyui-dialog"
				style="width: 400px; height: 300px; padding: 10px 10px"
				closed="true" buttons="#temFormManage-buttons" data-options="modal:true">
				<form id="lovManage"  method="post" enctype="multipart/form-data">
   				<%=eSession.local("xuanzewenjia.jsp.Title", "选择文件") %>：　<input id="uploadExcel"  runat="server" name="uploadExcel" style="width:200px" data-options="prompt:'请选择文件...'"type="file" />
<br>
   				<a style="position: relative;left:0;bottom:-160px;color:red" href="#"  onclick="exportDemo()" ><%=eSession.local("daochumuban.jsp.Title", "导出模板") %></a> 
   				</form> 
				
			</div>
			<div id="temFormManage-buttons">
			<a href="#" class="easyui-linkbutton" iconCls="icon-daoru" onclick="uploadExcel()" ><%=eSession.local("common.daoru", "导入") %></a> 
				<a class="easyui-linkbutton" iconCls="icon-cancel" 	onclick="javascript:$('#lovManageDlg').dialog('close')"><%=eSession.local("common.close", "取消") %></a>
			</div>
			<!-- 导入结束 -->
		</div>
</body>
<script type="text/javascript">
	$(function() {
		var dataGrid = $('#dg').edatagrid({
			destroyMsg : {
				norecord : { // 在没有记录选择的时候执行
					title : '<%=eSession.local("common.warning", "警告")%>',
					msg : '<%=eSession.local("lov.jsp.Title.noselect", "没有选择记录。") %>'
				},
				confirm : { // 在选择一行的时候执行
					title : '<%=eSession.local("common.info", "提示") %>',
					msg : '<%=eSession.local("common.confirm.remove.object", "确定要删除选中的信息吗?") %>'
				}
			},
			url : getRootPath() + '/LovController/getAllLovs.do',
		//	saveUrl : getRootPath() + '/LovController/saveLov.do',
		//	updateUrl : getRootPath()+'/LovController/saveLov.do',
		//	destroyUrl : getRootPath() + '/LovController/removeLov.do',
			onSave : function (index, row) {
				$.ajax({
					type : 'post',
					async : false,
					url : getRootPath() + '/LovController/saveLov.do',
					data : row,
					onSubmit : function() {
						return $(this).form('validate');
					},
					success : function(result) {
					},
					dataType : 'json'
				});
			},
			onDestroy : function (index, row) {
				$.ajax({
					type : 'post',
					async : false,
					url : getRootPath() + '/LovController/removeLov.do',
					data : row,
					success : function(result) {
					},
					dataType : 'json'
				});
			},
			
			remoteFilter : true,	//设置为true时，启用远程过滤
			filterDelay : 1000,		//延迟过滤 'text' 过滤器组件中最后一次键盘输入事件
			filterStringify : function(data) {	//字符串化过滤器规则的函数
				return JSON.stringify(data);
			} 
		});
		
		dataGrid.datagrid('enableFilter');
	});
function savelov(){
	$('#dg').edatagrid('addRow');
	$('#dg').edatagrid('reload');
		
	}
	function Export(){
		
		window.open(getRootPath() + '/LovController/exportExcel.do');
	}
</script>
</html>